<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/common/session.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=no, width=device-width">
    <title></title>
    <link rel="stylesheet" href="${ctx}/css/default.css"/>
    <script type="text/javascript" src="${ctx}/js/xtable.js"></script>
    <script type="text/javascript" src="${ctx}/js/calendar/WdatePicker.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/util.js"></script>
    <script type='text/javascript' src='${ctx}/dwr/interface/CategoryService.js'></script>
    <script type="text/javascript" src="${ctx}/js/loading.js"></script>
</head>
<body onload="$('categoryParentId1').click()">
<table id="categoryTable" width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td width="20%" valign="top">
            <form id="categoryForm" name="categoryForm" onsubmit="getOrderPage(); return false">
                <table cellspacing="5" cellpadding="5">
                    <tr>
                        <td>
                            <input type="radio" id="categoryParentId1" name="categoryParentId" value="1" onclick="categoryXTable.goPage(1)" checked/>
                            <label for="categoryParentId1">书籍</label>
                            <input type="radio" id="categoryParentId2" name="categoryParentId" value="2" onclick="categoryXTable.goPage(1)"/>
                            <label for="categoryParentId2">视频</label>
                            <input type="radio" id="categoryParentId19" name="categoryParentId" value="19" onclick="categoryXTable.goPage(1)"/>
                            <label for="categoryParentId19">音频</label>
                            <input type="radio" id="categoryParentId20" name="categoryParentId" value="20" onclick="categoryXTable.goPage(1)"/>
                            <label for="categoryParentId20">报纸</label>
                        </td>
                    </tr>
                </table>
            </form>
            <SCRIPT LANGUAGE="JavaScript" >
                var categoryThead = new Array(
                    new XThead("选择", "radio"),
                    new XThead("类别名称")
                );

                var categoryXTable = new XTable("category", categoryThead, true);

                categoryXTable.XTbodyArray = function (model) {
                    var array = new Array(
                        new XTbody("category", model.categoryId, "radio", "onclick='setCategory(this)'", model),
                        new XTbody("category", model.categoryName)
                    );
                    return array;
                }

                categoryXTable.getXList = function (page){
                    var category = dwr.util.getValues("categoryForm");
                    CategoryService.selectCategoryList(category, function(list){categoryXTable.addTable(list);});

                    var categoryParentId = dwr.util.getValue("categoryParentId");
                    var path = "${ctx}";
                    if (categoryParentId == 1) {
                        path += "/book/book_manage.jsp";
                    } else if (categoryParentId == 2) {
                        path += "/video/video_manage.jsp";
                    } else if (categoryParentId == 19) {
                        path += "/audio/audio_manage.jsp";
                    } else if (categoryParentId == 20) {
                        path += "/paper/paper_manage.jsp";
                    }
                    var homeFrame= document.getElementById("homeFrame");
                    homeFrame.src = path;
                    //homeFrame.height = document.documentElement.clientHeight * 2;
                }

            </SCRIPT>
        </td>
        <td width="80%" height="100%" valign="top">
            <iframe id="homeFrame" name="homeFrame" width="100%" height="3500" frameborder="0" scrolling="yes" marginwidth="0" marginheight="0" src=""></iframe>
        </td>
    </tr>
</table>
</body>
</html>
<script>
function setCategory(obj) {
    var category = obj.parentElement.parentElement.model;
    var categoryId = category.categoryId;
    var categoryParentId = category.categoryParentId;
    var path = "${ctx}";
    if (categoryParentId == 1) {
        path += "/book/book_manage.jsp?categoryId=" + categoryId;
    } else if (categoryParentId == 2) {
        path += "/video/video_manage.jsp?categoryId=" + categoryId;
    } else if (categoryParentId == 19) {
        path += "/audio/audio_manage.jsp?categoryId=" + categoryId;
    } else if (categoryParentId == 20) {
        path += "/paper/paper_manage.jsp?categoryId=" + categoryId;
    }
    var homeFrame= document.getElementById("homeFrame");
    homeFrame.src = path;
    //homeFrame.height = document.documentElement.clientHeight * 2;
}
</script>
